<?php
/**
 * 
 * @author yuxun
 *
 */

class ModRoleInfo {
	
	public function getListByRoleName($rolename,$develop_id){		
		$table = 'tbllog_role_info';		
		$sql = "SELECT rolename FROM ".$table." where server = '".$develop_id."' and rolename  LIKE '%".$rolename."%'; ";
		$dbName = 'mangologdb_role';
	
		$dbLink = new PubDbLink('dbFormalLog', $dbName);
	
		if(!$dbLink){
			return array();
		}
	
		$list = $dbLink->query($sql);
	
		return $list;
	}
	
	public function getListByRoleId($roleid,$develop_id){
		$table = 'tbllog_role_info';
		$sql = "SELECT roleid FROM ".$table." where server = '".$develop_id."' and roleid  LIKE '%".$roleid."%'; ";
		$dbName = 'mangologdb_role';
		
		$dbLink = new PubDbLink('dbFormalLog', $dbName);
		
		if(!$dbLink){
			return array();
		}
		
		$list = $dbLink->query($sql);
		
		return $list;
	}

	public function getListByOpenId($openid){
		$table = 'tbllog_role_info';
		$sql = "SELECT openid FROM ".$table." where openid  LIKE '%".$openid."%'; ";
		$dbName = 'mangologdb_role';
		
		$dbLink = new PubDbLink('dbFormalLog', $dbName);
		
		if(!$dbLink){
			return array();
		}
		
		$list = $dbLink->query($sql);
		
		return $list;
	}
	
	public function getRoleForOpenId($openid){
		$table = 'tbllog_role_info';
		$sql = "SELECT * FROM ".$table." where openid = '".$openid."'";
		$dbName = 'mangologdb_role';
		$dbLink = new PubDbLink('dbFormalLog', $dbName);
		
		if(!$dbLink){
			return array();
		}
		
		$list = $dbLink->query($sql);
		
		return $list;
	}
	
	public function getRoleName($roleid){
		$table = 'tbllog_role_info';
		$sql = "SELECT * FROM ".$table." where roleid = '".$roleid."'";
		$dbName = 'mangologdb_role';
		$dbLink = new PubDbLink('dbFormalLog', $dbName);
		
		if(!$dbLink){
			return '';
		}
		
		$list = $dbLink->query($sql);
		if(count($list) == 0){
			return '';
		}else{
			return $list[0]['rolename'];
		}
	}
    
    
} 